Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet
The is-glob npm package is used to determine if a string is a glob pattern. A glob pattern is a string that defines a pattern for matching file names, typically used for file searching and manipulation. The package provides a simple API to check if a string contains characters that make it a valid glob pattern.
Check if a string is a glob pattern
This feature allows you to check if a given string is a glob pattern. It returns true if the string contains special characters like '*', '?', or '[...]' that are used in glob patterns, and false otherwise.
const isGlob = require('is-glob');
console.log(isGlob('*.js')); // true
console.log(isGlob('hello.txt')); // false
Check if an array contains a glob pattern
This feature checks if any element in an array is a glob pattern. It returns true if at least one element is a glob pattern, and false if none are.
const isGlob = require('is-glob');
console.log(isGlob(['css', '*.js'])); // true
console.log(isGlob(['css', 'js'])); // false
Micromatch is a powerful, high-performance library for matching strings with glob patterns. It is more feature-rich than is-glob, providing advanced pattern matching, filtering, and conversion capabilities.
Minimatch is a minimal matching utility that implements the same glob pattern matching rules as used by npm. It is similar to is-glob but also includes the ability to match patterns against strings, not just check if a string is a glob.
Globby is a user-friendly glob matching utility built on top of micromatch. It extends the basic functionality of is-glob by providing methods to find files and directories in the file system using glob patterns.
Node-glob is a full-featured glob library that can match strings against patterns and also find files in the filesystem that match a given glob. It is more comprehensive than is-glob, which only checks if a string is a glob pattern.
Returns
true
if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a better user experience.
Please consider following this project's author, Jon Schlinkert, and consider starring the project to show your :heart: and support.
Install with npm:
$ npm install --save is-glob
You might also be interested in is-valid-glob and has-glob.
var isGlob = require('is-glob');
True
Patterns that have glob characters or regex patterns will return true
:
isGlob('!foo.js');
isGlob('*.js');
isGlob('**/abc.js');
isGlob('abc/*.js');
isGlob('abc/(aaa|bbb).js');
isGlob('abc/[a-z].js');
isGlob('abc/{a,b}.js');
//=> true
Extglobs
isGlob('abc/@(a).js');
isGlob('abc/!(a).js');
isGlob('abc/+(a).js');
isGlob('abc/*(a).js');
isGlob('abc/?(a).js');
//=> true
False
Escaped globs or extglobs return false
:
isGlob('abc/\\@(a).js');
isGlob('abc/\\!(a).js');
isGlob('abc/\\+(a).js');
isGlob('abc/\\*(a).js');
isGlob('abc/\\?(a).js');
isGlob('\\!foo.js');
isGlob('\\*.js');
isGlob('\\*\\*/abc.js');
isGlob('abc/\\*.js');
isGlob('abc/\\(aaa|bbb).js');
isGlob('abc/\\[a-z].js');
isGlob('abc/\\{a,b}.js');
//=> false
Patterns that do not have glob patterns return false
:
isGlob('abc.js');
isGlob('abc/def/ghi.js');
isGlob('foo.js');
isGlob('abc/@.js');
isGlob('abc/+.js');
isGlob('abc/?.js');
isGlob();
isGlob(null);
//=> false
Arrays are also false
(If you want to check if an array has a glob pattern, use has-glob):
isGlob(['**/*.js']);
isGlob(['foo.js']);
//=> false
When options.strict === false
the behavior is less strict in determining if a pattern is a glob. Meaning that
some patterns that would return false
may return true
. This is done so that matching libraries like micromatch have a chance at determining if the pattern is a glob or not.
True
Patterns that have glob characters or regex patterns will return true
:
isGlob('!foo.js', {strict: false});
isGlob('*.js', {strict: false});
isGlob('**/abc.js', {strict: false});
isGlob('abc/*.js', {strict: false});
isGlob('abc/(aaa|bbb).js', {strict: false});
isGlob('abc/[a-z].js', {strict: false});
isGlob('abc/{a,b}.js', {strict: false});
//=> true
Extglobs
isGlob('abc/@(a).js', {strict: false});
isGlob('abc/!(a).js', {strict: false});
isGlob('abc/+(a).js', {strict: false});
isGlob('abc/*(a).js', {strict: false});
isGlob('abc/?(a).js', {strict: false});
//=> true
False
Escaped globs or extglobs return false
:
isGlob('\\!foo.js', {strict: false});
isGlob('\\*.js', {strict: false});
isGlob('\\*\\*/abc.js', {strict: false});
isGlob('abc/\\*.js', {strict: false});
isGlob('abc/\\(aaa|bbb).js', {strict: false});
isGlob('abc/\\[a-z].js', {strict: false});
isGlob('abc/\\{a,b}.js', {strict: false});
//=> false
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
You might also be interested in these projects:
Commits | Contributor |
---|---|
47 | jonschlinkert |
5 | doowb |
1 | phated |
1 | danhper |
1 | paulmillr |
Jon Schlinkert
Copyright © 2019, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.8.0, on March 27, 2019.
FAQs
Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet
The npm package is-glob receives a total of 0 weekly downloads. As such, is-glob popularity was classified as not popular.
We found that is-glob demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.